package org.dt.common.sequence.dal;

import org.apache.commons.lang3.Validate;
import org.dt.common.sequence.CasDelegator;
import org.dt.common.sequence.SequenceHolder;
import org.dt.common.sequence.SequenceHolderFactory;
import org.dt.common.sequence.persist.CasSeqMapper;
import org.dt.common.sequence.spring.BaseSeqManagerConfiguration;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: yujiadong
 * @create: 2019/01/09 17:39
 **/
@Configuration
@MapperScan(basePackageClasses = {PolicyCasSeqMapper.class})
public class PolicySeqManagerConfiguration extends BaseSeqManagerConfiguration {

    @Override
    @Bean
    public CasDelegator delegator(CasSeqMapper mapper) {
        Validate.notNull(mapper);
        return new CasDelegator(mapper);
    }

    @Bean("policySequenceHolder")
    @Override
    public SequenceHolder sequenceHolder(SequenceHolderFactory sequenceHolderFactory) {
        return sequenceHolderFactory.sequenceHolder("policy");
    }

    @Bean("endorsementSequenceHolder")
    public SequenceHolder sequenceHolder1(SequenceHolderFactory sequenceHolderFactory) {
        return sequenceHolderFactory.sequenceHolder("endorsement");
    }

}
